# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Maxime de Roucy <maxime.deroucy@gmail.com>
# Contributor: Darwin Bautista <djclue917@gmail.com>

pkgname=gsm
pkgver=1.0.19
pkgrel=1
pkgdesc="Shared libraries for GSM 06.10 lossy speech compression"
arch=('x86_64')
url="http://www.quut.com/gsm/"
license=('custom')
depends=('glibc')
source=("http://www.quut.com/$pkgname/$pkgname-$pkgver.tar.gz" gsm-shared.patch)
sha512sums=('f69b4bf2d918b118b5de90b8ab88fd026008ac7432f07b872b81fe52cdc781f605dca8eedcdaebc8beb974cef388496c618f92a41961c62057009964159f8392'
            'ece13a62503a50173a9fbf43d939f643d5a831a0208f13b108708989f73db63f9e3a5ac04c30ab11533ae19ad9e0ff348436a1184bb2a173518970d87da04b78')

prepare() {
  cd $pkgname-${pkgver%.*}-pl${pkgver##*.}

  patch -p0 -i ../gsm-shared.patch
}

build() {
  cd $pkgname-${pkgver%.*}-pl${pkgver##*.}

  make CCFLAGS="-c ${CFLAGS} -fPIC"
}

package() {
  cd $pkgname-${pkgver%.*}-pl${pkgver##*.}

  # Prepare directories
  install -m755 -d "$pkgdir"/usr/{bin,lib,include/gsm,share/{licenses/$pkgname,man/man{1,3}}}

  make -j1 INSTALL_ROOT="$pkgdir"/usr \
    GSM_INSTALL_INC="$pkgdir"/usr/include/gsm \
    GSM_INSTALL_MAN="$pkgdir"/usr/share/man/man3 \
    TOAST_INSTALL_MAN="$pkgdir"/usr/share/man/man1 \
    install

  # Install license
  install -m644 COPYRIGHT "$pkgdir"/usr/share/licenses/$pkgname/license.txt
}
